<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<a href="/logout">注销</a>
    hello shiro!

<script th:src="@{/layui-v2.6.8/layui/layui.js}"></script>
<script src="/jquery-3.6.js"></script>
<script>


  var websocket;
  websocket = new WebSocket('ws://localhost:8080/websocket');

  websocket.onopen=function (event) {
    console.log("连接");
  }
  websocket.onclose=function (event){
    console.log("关闭")
  }
  websocket.onmessage=function (event){
    console.log("收到消息："+event.data)
    layer.msg(event.data);
  }
  window.onbeforeunload=function (event){
    websocket.close();
  }
  </script>
</body>
</html>
